import { Component } from 'react'
import './Header.less'
class Header extends Component {
  state = {
    title: '',
    content: '',
  }
  addContent = () => {
   
      const { title, content } = this.state
      this.props.CommentList({ title, content })
      this.setState({
        title: '',
        content: '',
      })
    
  }
  // 获取评论人信息
  people = (e) => {
    let title = e.target.value
    this.setState({
      title,
    })
  }
  // 获取评论内容
  comment = (e) => {
    let content = e.target.value
    this.setState({
      content,
    })
  }
  render() {
    return (
      <div className="comment1">
        {/* 搜索评论人 */}
        <div className="search">
          <input
            type="text"
            placeholder="请输入评论人"
            value={this.state.title}
            onChange={this.people}
          />
          <textarea
            placeholder="请输入评论内容"
            rows="9"
            value={this.state.content}
            onChange={this.comment}
          ></textarea>
        </div>
        <div className="btn-add">
          <button onClick={this.addContent}>发表评论</button>
        </div>
      </div>
    )
  }
}

export default Header
